<script setup>
import useLogin from "./login";
import useReset from "./reset";
import useSubmit from "./submit";

// 表单验证
let { formSize, ruleForm, rules } = useLogin();
// 重置按钮
let { resetForm } = useReset();
// 登录按钮
let { submitForm, ruleFormRef } = useSubmit({
  formRef: "ruleFormRef",
  ruleForm,
});
</script>

<template>
  <div class="login">
    <!-- 图片部分 -->
    <div class="img-box">
      <img src="@/assets/logo.png" alt="" />
    </div>
    <!-- 表单 -->

    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      class="demo-ruleForm"
      :size="formSize"
      status-icon
    >
      <el-form-item prop="username">
        <el-input v-model="ruleForm.username" />
      </el-form-item>
      <el-form-item prop="password">
        <el-input type="password" show-password v-model="ruleForm.password" />
      </el-form-item>

      <el-form-item>
        <!-- 登录按钮 -->
        <el-button type="primary" @click="submitForm(ruleFormRef)">
          登录
        </el-button>
        <!-- 重置按钮 -->
        <el-button @click="resetForm(ruleFormRef)">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
.login {
  background: #2b4b6b;
  height: 100vh;
  position: relative;
}
.demo-ruleForm {
  width: 500px;
  height: 300px;
  background: white;
  padding: 20px;
  border-radius: 10px;
  padding-top: 100px;
  box-sizing: border-box;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  margin-top: 250px;
}
.img-box {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: white;
  padding: 8px;
  z-index: 2;
  border: 1px solid #ddd;

  position: absolute;
  // left: 50%;
  // transform: translate(-50%, 180%);
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  // transform: translate(0 120px);
  margin-top: 180px;
  img {
    width: 100%;
    height: 100%;
    background: #dddddd;
    border-radius: 50%;
  }
}

.el-btns {
  float: right;
}
</style>